home *** CD-ROM | disk | FTP | other *** search
- Path: news1.intercall.com!usenet
- From: engevar@intercall.com (Steven Ovits)
- Newsgroups: comp.lang.c++
- Subject: Re: Virtual function does not make any sense unless it is pure.
- Date: Mon, 15 Apr 1996 12:29:05 GMT
- Organization: Intercall Inc.
- Message-ID: <4kt62v$9a4@news1.intercall.com>
- References: <4kkhbc$nj4@brahms.udel.edu> <316E9AC3.1124@zurich.ibm.com>
- NNTP-Posting-Host: 206.98.168.162
- X-Newsreader: Forte Free Agent 1.0.82
-
- Yue-hong Zheng wrote:
- > Can any body give me any examples to show non-pure
- > virtual function does make sense?
-
- This example could be used in a windowing system
- to make a hidden window. Ms-Windows programmers
- will recognize this as a Modalless dialog box
- courtesy of Jeffrey M. Richter from "Windows 3.1:
- A Developer's Guide." (ie, It's a practical example.)
-
- struct win {
- void show() { ::show(w); }
- int w;
- };
-
- // most derived types use win::show()
- // for example:
- struct button : public win {
- // uses win::show to display the window
- // other button code also goes here
- };
-
- struct hack_to_make_hidden_window : public win {
- void show() { if (enabled) win::show(); }
- int enabled;
- };
-
-
-